/*
 * HudRectangle.fx
 */

package org.frapwidgets.scene.shape.hud;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.layout.Resizable;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;


/**
 * A HUD button rectangle, which is the main component of HUD buttons.
 *
 * The button has a one-pixel edge, with a given fill, and a central region,
 * with a different fill.
 *
 * @author Jonathan Merritt
 */
public class HudButtonRectangle extends CustomNode, Resizable {

  override public var width on replace {
    oRect.width = width;
    iRect.width = width-2;
  }
  override public var height on replace {
    oRect.height = height;
    iRect.height = height-2;
  }

  public-init var arcDiam: Number;
  public-init var edgePaint: Paint;
  public-init var fillPaint: Paint;

  def oRect = Rectangle {
    fill: edgePaint,
    arcWidth: arcDiam,
    arcHeight: arcDiam
  };
  def iRect = Rectangle {
    def a = arcDiam - 2;
    x: 1, y: 1,
    fill: fillPaint, 
    arcWidth: a,
    arcHeight: a
  };

  def node = Group { content: [ oRect, iRect ] }

  override public function getPrefHeight (arg0 : Number) : Number { 0 }
  override public function getPrefWidth (arg0 : Number) : Number { 0 }

  override function create(): Node { node }
}
